package com.iu.eblood.daoImpl;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.iu.eblood.dao.GenericDao;
import com.iu.eblood.daoInterfaces.EventDao;
import com.iu.eblood.model.Event;
import com.iu.eblood.model.User;


@Repository
public class EventDaoImpl
extends GenericDao<Event,Long>
implements EventDao{

	public EventDaoImpl() {
		super(Event.class);
		
	}
	
	
	public List<Event> pastEvent(String isActive) 
	{
	
		Session ses=getHibernateTemplate().getSessionFactory().getCurrentSession();
	return	ses.createQuery("from Event as e where e.finishdate <:currentDate and isactive=:state").
			setTimestamp("currentDate",Calendar.getInstance().getTime()).setString("state",isActive).list();


	}
	
	public List<Event> comingEvent(String isActive)
	{
		Session ses=getHibernateTemplate().getSessionFactory().getCurrentSession();
		return	ses.createQuery("from Event as e where e.finishdate >:currentDate and isactive=:state").
				setTimestamp("currentDate",Calendar.getInstance().getTime()).setString("state",isActive).list();

	}

	
}
